home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_203 / gurusguide / simple.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  83 lines

  1. /************************************************************************
  2. **********                                                     **********
  3. **********           S I M P L E   I N T E R R U P T           **********
  4. **********           -------------------------------           **********
  5. **********                                                     **********
  6. **********        Copyright (C) 1988 Sassenrath Research       **********
  7. **********                All Rights Reserved.                 **********
  8. **********                                                     **********
  9. **********    Example from the "Guru's Guide, Meditation #1"   **********
  10. **********                                                     **********
  11. *************************************************************************
  12. **                                                                     **
  13. **                            - NOTICE -                               **
  14. **                                                                     **
  15. **  The "Guru's Guide, Meditation #1" contains detailed information    **
  16. **  about Amiga interrupts as well as a complete discussion of this    **
  17. **  and other examples.  Meditation #1 and all of its examples were    **
  18. **  written by Carl Sassenrath, the architect of Amiga's multitasking  **
  19. **  operating system.  Copies of the "Guru's Guide" may be obtained    **
  20. **  from:                                                              **
  21. **           GURU'S GUIDE, P.O. BOX 1510, UKIAH, CA 95482              **
  22. **                                                                     **
  23. **  Please include a check for $14.95, plus $1.50 shipping ($4.00 if   **
  24. **  outside North America).  CA residents add 6% sales tax.            **
  25. **                                                                     **
  26. **  This example may be used for any purposes, commercial, personal,   **
  27. **  public, and private, so long as ALL of the above text, copyright,  **
  28. **  mailing address, and this notice are retained in their entirety.   **
  29. **                                                                     **
  30. **  THIS EXAMPLE IS PROVIDED WITHOUT WARRANTY OF ANY KIND.             **
  31. **                                                                     **
  32. ************************************************************************/
  33.  
  34. /*
  35. **  COMPILATION NOTE:
  36. **
  37. **  Compiled under MANX AZTEC C 3.6A.  Use the +L compiler option
  38. **  and the "c32" library.
  39. */
  40.  
  41.  
  42. #include <exec/interrupts.h>
  43. #include <hardware/intbits.h>
  44.  
  45. VOID    IntrProc();    /* forward to interrupt code */
  46. long    IntrCount;    /* vertical blank counter     */
  47.  
  48. /* Initialized interrupt structure */
  49. struct Interrupt VertBlank =
  50. {
  51.     NULL,            /* node pred*/
  52.     NULL,            /* node succ*/
  53.     -60,            /* node pri */
  54.     NT_INTERRUPT,        /* node type*/
  55.     "simple.example",    /* node name*/
  56.     (APTR)&IntrCount,    /* data ptr */
  57.     &IntrProc        /* code ptr */
  58. };
  59.  
  60.  
  61. #asm    /* Interrupt Server Code */
  62. _IntrProc:
  63.         addq.l    #1,(a1)    ; increment IntrCount
  64.         moveq    #0,d0    ; Z-flag - do next server
  65.         rts
  66. #endasm
  67.  
  68.  
  69. main()    /* Initialization, Main, and Clean-up */
  70. {
  71.     extern int Enable_Abort;
  72.  
  73.     Enable_Abort = 0;    /* prevent a CTRL-C */
  74.  
  75.     IntrCount = 0;
  76.  
  77.     AddIntServer(INTB_VERTB, &VertBlank);
  78.  
  79.     while (IntrCount < 200) printf("%d\n",IntrCount);
  80.  
  81.     RemIntServer(INTB_VERTB, &VertBlank);
  82. }
  83.